package com.aliware.edas;

import com.alibaba.fastjson.JSON;
import com.aliyun.api.EchoService;
import com.aliyun.api.FlightDelay;
import com.aliyun.model.EchoBean;
import com.aliyun.model.FlightInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
public class SimpleController {


    @Autowired
    private EchoService echoService;

    @Autowired FlightDelay flightDelay;

    @RequestMapping(value = "/hsf-echo", method = RequestMethod.POST)
    public String echo(@RequestBody EchoBean echoBean) {
        return echoService.echo(echoBean);
    }

    @RequestMapping(value = "/hsf-echo/{str}", method = RequestMethod.GET)
    public String echo(@PathVariable String str) {
        return echoService.echoString(str);
    }

    @RequestMapping(value = "/hsf-flightDelay/{flightNumber}", method = RequestMethod.GET)
    public FlightInfo flightDelay(@PathVariable String flightNumber) {
        FlightInfo flightInfo = flightDelay.flightInformation(flightNumber);
        return flightInfo;//JSON.toJSONString(flightInfo);
    }
}
